package com.zhiyin.seal.constant;

import java.util.Arrays;
import java.util.Optional;

/**
 * 审批状态
 */
public enum ApprovalStatusEnum implements BaseEnum {

    PENDING_APPROVAL(0, "待审批"),

    IN_APPROVAL(1, "审批中"),

    APPROVED(2, "已审批"),

    REJECT(3, "已驳回"),

    REVOKE(4, "已撤销");

    private Integer value;
    private String desc;

    ApprovalStatusEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public Integer getValue() {
        return value;
    }
    @Override
    public String getDesc() {
        return desc;
    }

    public static JudgeEnum valueOf(Integer status) {
        JudgeEnum[] values = JudgeEnum.values();
        Optional<JudgeEnum> first = Arrays.stream(values).filter(e -> e.getValue().equals(status)).findFirst();
        return !first.isPresent() ? null : first.get();
    }

    public static boolean isExist(Integer status) {
        JudgeEnum judgeEnum = valueOf(status);
        return judgeEnum != null;
    }
}
